const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");


module.exports = {
    context: path.resolve(__dirname, './src'),
    entry: {
        app: ['./bootstrap/index.js'],
        vendor: ["react", "react-dom","antd"]
    },
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: '[name].bundle.[hash:8].js'
    },
    resolve: {
        alias: {
            'rxjs': 'rxjs-es'
        }
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: [/node_modules/],
                use: [{
                    loader: 'babel-loader',
                    options: { presets: ['es2015','react']
                    }
                }]
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
            },
            {
                test: /\.(png|jpg)$/,
                loader: 'file-loader?limit=8192&name=images/[hash:8].[name].[ext]'
            }
        ]
    },
    devtool: "source-map",
    plugins: [
        new HtmlWebpackPlugin(
            {template:'./index.html'}
        ),
        new ExtractTextPlugin("styles.[hash:8].css"),
        new webpack.optimize.CommonsChunkPlugin({
            name: "vendor",
            minChunks: Infinity
        })

       ]
}